package com.wang.nowcoder.util;

/**
 * @author wang
 * @ClassName RedisKeyUtil
 * @Description RedisKey工具类
 * @date 2021/12/27 14:37
 * @Version 1.0
 */
public class RedisKeyUtil {
    private static final String SPLIT = ":";
    private static final String PREFIX_POJO_LIKE = "like:pojo";
    private static final String PREFIX_USER_LIKE = "like:user";
    private static final String PREFIX_FOLLOW = "follow";
    private static final String PREFIX_FOLLOWER = "follower";


    /**
     * 某个实体的赞
     * @param pojoType
     * @param pojoId
     * @return
     */
    public static String getPojoLikeKey(int pojoType,int pojoId){
        return PREFIX_POJO_LIKE + SPLIT + pojoType + SPLIT + pojoId;
    }

    /**
     *某个用户的赞
     * @param userId
     * @return
     */
    public static String getUserLikeKey(int userId){
        return PREFIX_USER_LIKE + SPLIT + userId;
    }

    /**
     * 某个用户关注的实体
     * @param userId
     * @param pojoType
     * @return
     */
    public static String getFollowKey(int userId,int pojoType){
        return PREFIX_FOLLOW + SPLIT +userId +SPLIT + pojoType;
    }

    /**
     * 某个实体拥有的粉丝
     * @param pojoType
     * @return
     */
    public static String getFollowerKey(int pojoType,int pojoId){
        return PREFIX_FOLLOWER + SPLIT +pojoType +SPLIT +pojoId;
    }
}
